package com.cskaoyan.service;

import com.cskaoyan.bean.MarketGoodsProduct;
import com.cskaoyan.mapper.MarketGoodsProductMapper;
import com.cskaoyan.util.TransactionUtil;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author stone
 * @date 2023/03/18 02:04
 */
public class GoodsProductServiceImpl implements GoodsProductService {
    @Override
    public int addStock(Integer productId, Short number) {
        MarketGoodsProductMapper goodsProductMapper = TransactionUtil.getSqlSession().getMapper(MarketGoodsProductMapper.class);
        return goodsProductMapper.addStock(productId, number);
    }

    @Override
    public int add(MarketGoodsProduct product) {
        //TransactionUtil.startTransaction();

        MarketGoodsProductMapper goodsProductMapper = TransactionUtil.getMapper(MarketGoodsProductMapper.class);
        Date now = new Date();
        product.setAddTime(now);
        product.setUpdateTime(now);
        int insert = goodsProductMapper.insertSelective(product);

        //TransactionUtil.commit();
        return insert;
    }
}
